package Mypackage.Runner;

/**
 * Created by IntelliJ IDEA.
 * User: nadya
 * Date: Apr 7, 2011
 * Time: 11:46:30 PM
 * To change this template use File | Settings | File Templates.
 */


import com.intellij.execution.configurations.ConfigurationFactory;
import com.intellij.execution.configurations.ConfigurationType;
import com.intellij.execution.configurations.RunConfiguration;
import com.intellij.execution.configurations.RunConfigurationModule;
import com.intellij.openapi.extensions.Extensions;
import com.intellij.openapi.project.Project;
import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.NotNull;

import javax.swing.*;
import java.awt.*;

public class PerlConfigurationType implements ConfigurationType {
  private final ConfigurationFactory myFactory;
  
  public PerlConfigurationType() {
    myFactory = new ConfigurationFactory(this) {
            @Override
            public RunConfiguration createTemplateConfiguration(Project project) {
                return new PerlRunConfiguration(new RunConfigurationModule(project), this, "");
            }
    };
  }
    public String getDisplayName() {
        return "Perl Script";
    }

    public String getConfigurationTypeDescription() {
        return "Perl run configuration";
    }

    public Icon getIcon() {
        return new Icon() {
            public void paintIcon(Component c, Graphics g, int x, int y) {
                //To change body of implemented methods use File | Settings | File Templates.
            }

            public int getIconWidth() {
                return 32;  //To change body of implemented methods use File | Settings | File Templates.
            }

            public int getIconHeight() {
                return 32;  //To change body of implemented methods use File | Settings | File Templates.
            }
        };
    }

    @NotNull
    public String getId() {
        return "#com.sylvanaar.idea.Perl.run.PerlConfigurationType";
    }

    public static PerlConfigurationType getInstance() {
        return ContainerUtil.findInstance(Extensions.getExtensions(CONFIGURATION_TYPE_EP), PerlConfigurationType.class);
    }

    public ConfigurationFactory[] getConfigurationFactories() {
        return new ConfigurationFactory[]{myFactory};
    }

//    private static class PerlConfigurationFactory extends ConfigurationFactory {
//        public PerlConfigurationFactory(ConfigurationType confType) {
//            super(confType);
//        }
//
//        @Override
//        public RunConfiguration createTemplateConfiguration(Project project) {
//         //   PerlInterpreterDetection PerlDetector = new PerlInterpreterDetection();
//
//            PerlRunConfiguration configuration = new PerlRunConfiguration(new RunConfigurationModule(project), this, "");
//           // configuration.setInterpreterPath(PerlDetector.findBestLocation());
//            configuration.setInterpreterPath("Perl");
//            return configuration;
//        }
//    }
    
}